package cn.gok.servlet;

import java.io.IOException;

/**
 * @Author: chenfan
 * @Date: 2020/12/6 18:35
 * @Description:
 */
public abstract class HttpServlet implements Servlet {


    @Override
    public void init() throws Exception {
        System.out.println(" ========Servlet init===== ");
    }

    @Override
    public void destory() throws Exception {
        System.out.println(" ========Servlet destory===== ");
    }

    public abstract void doGet(MyRequest request, MyResponse response) throws IOException;

    public abstract void doPost(MyRequest request,MyResponse response);

    @Override
    public void service(MyRequest request, MyResponse response) throws Exception {
        if ("GET".equalsIgnoreCase(request.getMethod())){
            doGet(request,response);
        }else{
           doPost(request, response);
        }
    }


}
